//
//  CancelOrderOrDepositViewController.m
//  ShoppingExperience
//
//  Created by LiYinDi on 15/9/26.
//  Copyright (c) 2015年 RuiBen. All rights reserved.
//

#import "CancelOrderOrDepositViewController.h"
#import "GuideListTableViewCell.h"
#import "FPNumberPadView.h"
@interface CancelOrderOrDepositViewController ()<FPNumberPadViewDelegate>
{
    BOOL guideIsOpen;
    NSMutableArray *guideCodeArray;
    NSMutableArray *guideNameArray;
    NSString *guideCodeStr;
    
    NSString *memberCodeStr;
   
    
}
@end

@implementation CancelOrderOrDepositViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    FPNumberPadView *numberPadView = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
    numberPadView.FPNumberPaddelegate=self;
    
    numberPadView.textField = _refundMoneyTextField;

    guideCodeArray=[NSMutableArray array];
    guideNameArray=[NSMutableArray array];
    guideIsOpen=NO;
    guideCodeStr=[Global getGuideCodeStr];
    _guideNameLabel.text=[Global getGuideNameStr];
    //[self resizeLabel1:_guideNameLabel];
    [Global resizeForLable:_guideNameLabel WithText:_guideNameLabel.text parentView:self.view];
    CGRect frameK=_guideNameLabel.frame;
    frameK.origin.x=_guideNameArrow.frame.origin.x-frameK.size.width-5;
    _guideNameLabel.frame=frameK;
    
    _switch1.backgroundColor = [UIColor clearColor];
    // _switch1.tintColor = [UIColor orangeColor];
    
    _cancelDepositMoneyView.hidden=YES;
  
    CGRect rect1=_lastView.frame;
    rect1.origin.y=369;
    _lastView.frame=rect1;
    _switch1.onTintColor = [UIColor colorWithRed:210.0f/255.0f green:171.0f/255.0f blue:57.0f/255.0f alpha:1.0f];
    _switch1.tintColor = [UIColor colorWithRed:194.0f/255.0f green:194.0f/255.0f blue:194.0f/255.0f alpha:1.0f];
    
    
    _switch1.onText = @"是";
    _switch1.on=NO;
    _switch1.offText = @"否";
    
    [_switch1 addTarget:self action:@selector(handleSwitchEvent:) forControlEvents:UIControlEventValueChanged];
    // Do any additional setup after loading the view from its nib.
    _textView.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
    _textView.layer.borderWidth= 1.0f;
    _textView.layer.cornerRadius=3;
    
     [_guideListBtn addTarget:self action:@selector(selectGuideBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    [_alphaView setBackgroundColor:[Global parseColor:WESTORE_TRANSCLUCENT]];
    [_alphaView addTarget:self action:@selector(alphaViewClick) forControlEvents:UIControlEventTouchUpInside];
   // memberCodeStr=@"";
    
    _titleNameLabel.text=_titleStr;
    
    

    [self requestDetail];
    

}
-(void)requestDetail
{
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        [params setObject:_DocTypeStr forKey:@"DocType"];
        [params setObject:_DocNumStr forKey:@"DocNum"];
      //  NSLog(@"plll===%@",params);
        
        [HttpRequest requestData:@"Guide/GatheringDetail" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                   // NSLog(@"ttttt===%@",severDataDict.dataDict);
                    NSString *status1=[severDataDict.dataDict objectForKey:@"DocStatus"];
                     NSString *status2=@"";
                    if ([severDataDict.dataDict objectForKey:@"DocStatus2"]!=[NSNull null]) {
                        status2= [severDataDict.dataDict objectForKey:@"DocStatus2"];
                    }
                  
                  
                    if ([status1 isEqualToString:@"已取消"]||[status2 isEqualToString:@"已使用"]) {
                        _cancelDepositView.hidden=YES;
                        // NSLog(@"rrrrr");
                    }
                    else
                    {
                        _cancelDepositView.hidden=NO;
                    }

                    NSString *nameStr=@"";
                    NSString *phoneStr=@"";
                    if ([severDataDict.dataDict objectForKey:@"MemberName"]!=[NSNull null]) {
                        nameStr=[severDataDict.dataDict objectForKey:@"MemberName"];
                    }
                    if ([severDataDict.dataDict objectForKey:@"Phone"]!=[NSNull null]) {
                        phoneStr =[severDataDict.dataDict objectForKey:@"Phone"];
                    }
                    
                    // memberCodeStr=[memberCodeArray objectAtIndex:indexPath.row];
                    //  NSString *integralStr=[memberIntegralArray objectAtIndex:indexPath.row];
                    _memberAndPhoneLabel.text=[NSString stringWithFormat:@"%@(%@)",nameStr,phoneStr];
                    memberCodeStr=[severDataDict.dataDict objectForKey:@"MemberCode"];
                    if (memberCodeStr.length>0) {
                        _memberNoteLabel.hidden=YES;
                    }
                    else
                    {
                         _memberNoteLabel.hidden=NO;
                    }
                    if (_memberAndPhoneLabel.text.length>0) {
                        
                     //   [self resizeLabel:_memberAndPhoneLabel];
                        [Global resizeForLable:_memberAndPhoneLabel WithText:_memberAndPhoneLabel.text parentView:self.view];
                        
                        if ([severDataDict.dataDict objectForKey:@"Grade"]!= [NSNull null])
                        {
                            NSString *gradeStr=[severDataDict.dataDict objectForKey:@"Grade"];
                            _memberGradeLabel.text=gradeStr;
                            _memberGradeTagLabel.hidden=NO;
                            _memberGradeLabel.hidden=NO;
                          //  [self resizeLabel:_memberGradeLabel];
                             [Global resizeForLable:_memberGradeLabel WithText:_memberGradeLabel.text parentView:self.view];
                            //_memberGradeLabel.text=[severDataDict.dataDict objectForKey:@"Grade"];
                        }
                        
                        CGRect frame=_memberGradeTagLabel.frame;
                        frame.origin.x=_memberAndPhoneLabel.frame.origin.x+_memberAndPhoneLabel.frame.size.width+12;
                        _memberGradeTagLabel.frame=frame;
                        
                        CGRect frame1=_memberGradeLabel.frame;
                        frame1.origin.x=_memberGradeTagLabel.frame.origin.x+_memberGradeTagLabel.frame.size.width+2;
                        _memberGradeLabel.frame=frame1;
                        
                        CGRect frame2=_memberIntegralTagLabel.frame;
                        frame2.origin.x=_memberGradeLabel.frame.origin.x+_memberGradeLabel.frame.size.width+12;
                        _memberIntegralTagLabel.frame=frame2;
                    }
                    
                    if ([severDataDict.dataDict objectForKey:@"Integral"]!= [NSNull null] )
                    {
                        _memberIntegralLabel.text=[NSString stringWithFormat:@"%ld",[[severDataDict.dataDict objectForKey:@"Integral"] integerValue]];
                     //   [self resizeLabel:_memberIntegralLabel];
                     [Global resizeForLable:_memberIntegralLabel WithText:_memberIntegralLabel.text parentView:self.view];
                        CGRect frame=_memberIntegralLabel.frame;
                        frame.origin.x=_memberIntegralTagLabel.frame.origin.x+_memberIntegralTagLabel.frame.size.width+2;
                        _memberIntegralLabel.frame=frame;
                        
                        }
                    if ([severDataDict.dataDict objectForKey:@"GuideName"]!=[NSNull null]) {
                        _guideNameLabel.text=[severDataDict.dataDict objectForKey:@"GuideName"];
                       // [self resizeLabel:_guideNameLabel];
                        
                        [Global resizeForLable:_guideNameLabel WithText:_guideNameLabel.text parentView:self.view];
                        CGRect frameK=_guideNameLabel.frame;
                        frameK.origin.x=_guideNameArrow.frame.origin.x-frameK.size.width-5;
                        _guideNameLabel.frame=frameK;
                    }
                    

                     NSString *dateStr=[severDataDict.dataDict objectForKey:@"DocDate"];
                    _dateLabel.text=dateStr;
                    [Global resizeForLable:_dateLabel WithText:_dateLabel.text parentView:self.view];
                    
                    CGRect framea=_priceLabel.frame;
                    framea.origin.x=_dateLabel.frame.origin.x+_dateLabel.frame.size.width+10;
                    _priceLabel.frame=framea;
                    
                    NSString *priceStr=[NSString stringWithFormat:@"¥%0.02f",[[severDataDict.dataDict objectForKey:@"DocTotal"] floatValue]];
                    _priceLabel.text=priceStr;
                    NSString *numStr=[severDataDict.dataDict objectForKey:@"DocNum"];
                    _numLabel.text=numStr;
                   // [self resizeLabel:_numLabel];
                     [Global resizeForLable:_numLabel WithText:_numLabel.text parentView:self.view];
                    
                    CGRect framep=_statusLabel.frame;
                    framep.origin.x=_numLabel.frame.origin.x+_numLabel.frame.size.width+2;
                    _statusLabel.frame=framep;
                    
                     NSString *SubscriptionStr=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"Subscription"] floatValue]];
                    NSString *statusStr=[severDataDict.dataDict objectForKey:@"DocStatus"];
                    _cancelDepositView.hidden=NO;
                    _statusLabel.text=[NSString stringWithFormat:@"【%@】",statusStr];;
                    if ([statusStr isEqualToString:@"未收银"]) {
                        [_statusLabel setTextColor:[Global parseStatusColor:statusStr]];
                        if ([SubscriptionStr floatValue]==0) {
                            _cancelDepositView.hidden=YES;
                              _orderView.hidden=YES;
                        }
                    }
                    else if ([statusStr isEqualToString:@"已取消"])
                    {
                        [_statusLabel setTextColor:[Global parseStatusColor:statusStr]];
                    }
                    else if ([statusStr isEqualToString:@"已收定金"])
                    {
                        [_statusLabel setTextColor:[Global parseStatusColor:statusStr]];
                    }
                    else if ([statusStr isEqualToString:@"已结算"])
                    {
                        [_statusLabel setTextColor:[Global parseStatusColor:statusStr]];
                    }
                    [Global resizeForLable:_statusLabel WithText:_statusLabel.text parentView:self.view];
                    
                    if ([_DocTypeStr isEqualToString:@"Deposit"]) {
                        _orderView.hidden=YES;
                        NSString *statusStr2=[NSString stringWithFormat:@"%@",[severDataDict.dataDict objectForKey:@"DocStatus2"]];
                        _docTypeLabel.text=[NSString stringWithFormat:@"【%@】",statusStr2];
                        CGRect frameg=_docTypeLabel.frame;
                        frameg.origin.x=_statusLabel.frame.origin.x+_statusLabel.frame.size.width-5;
                        _docTypeLabel.frame=frameg;
                        
                        if ( [statusStr2 isEqualToString:@"未使用"]) {
                            [_docTypeLabel setTextColor:[Global parseStatusColor:statusStr2]];
                            
                        }
                        else if ([statusStr2 isEqualToString:@"已使用"]) {
                            [_docTypeLabel setTextColor:[Global parseStatusColor:statusStr2]];
                        }
                    }
                    else
                    {
                        _orderView.hidden=NO;
                    }

                   
                    NSString *IntegralAmountStr=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"IntegralAmount"] floatValue]];
                    NSString *DecutibleStr=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"Rebate"] floatValue]];
                    NSString *OldMaterialStr=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"OldMaterial"] floatValue]];
                    
                    _integralLabel.text=IntegralAmountStr;
                    _decutibleLabel.text=DecutibleStr;
                    _oldLabel.text=OldMaterialStr;
                   // [self resizeLabel:_integralLabel];
                     [Global resizeForLable:_integralLabel WithText:_integralLabel.text parentView:self.view];
                    // [self resizeLabel:_decutibleLabel];
                     [Global resizeForLable:_decutibleLabel WithText:_decutibleLabel.text parentView:self.view];
                   // [self resizeLabel:_oldLabel];
                     [Global resizeForLable:_oldLabel WithText:_oldLabel.text parentView:self.view];
                     _depositLabel.text=SubscriptionStr;
                   //  [self resizeLabel:_depositLabel];
                     [Global resizeForLable:_depositLabel WithText:_depositLabel.text parentView:self.view];
                    if ([SubscriptionStr floatValue]>0) {
                        _depositLabel.hidden=NO;
                        _depositTagLabel.hidden=NO;
                        _noteView.hidden=NO;
                        //_depositLabel.text=SubscriptionStr;
                        
                        CGRect framea=_cancelDepositView.frame;
                        framea.origin.y=350;
                        _cancelDepositView.frame=framea;
                        
                        CGRect frameb=_lastView.frame;
                        frameb.origin.y=510;
                        _lastView.frame=frameb;

                       
                        CGRect framed=_integralTagLabel.frame;
                        framed.origin.x=_depositLabel.frame.origin.x+_depositLabel.frame.size.width+12;
                        _integralTagLabel.frame=framed;
                    }
                    else
                    {
                        CGRect framea=_cancelDepositView.frame;
                        framea.origin.y=285;
                        _cancelDepositView.frame=framea;
                        
                        CGRect frameb=_lastView.frame;
                        frameb.origin.y=441;
                        _lastView.frame=frameb;

                        _noteView.hidden=YES;
                        _depositLabel.hidden=YES;
                        _depositTagLabel.hidden=YES;
                       
                        CGRect framed=_integralTagLabel.frame;
                        framed.origin.x=_tagLabel.frame.origin.x+_tagLabel.frame.size.width+5;
                        _integralTagLabel.frame=framed;
                    }
                  
                    
                    CGRect framee=_integralLabel.frame;
                    framee.origin.x=_integralTagLabel.frame.origin.x+_integralTagLabel.frame.size.width+2;
                    _integralLabel.frame=framee;
                    
                    CGRect framec=_decutibleTagLabel.frame;
                    framec.origin.x=_integralLabel.frame.origin.x+_integralLabel.frame.size.width+12;
                    _decutibleTagLabel.frame=framec;
                    
                    CGRect framef=_decutibleLabel.frame;
                    framef.origin.x=_decutibleTagLabel.frame.origin.x+_decutibleTagLabel.frame.size.width+2;
                    _decutibleLabel.frame=framef;
                    
                    CGRect framet=_oldTagLabel.frame;
                    framet.origin.x=_decutibleLabel.frame.origin.x+_decutibleLabel.frame.size.width+10;
                    _oldTagLabel.frame=framet;
                    
                    CGRect framey=_oldLabel.frame;
                    framey.origin.x=_oldTagLabel.frame.origin.x+_oldTagLabel.frame.size.width+2;
                    _oldLabel.frame=framey;
                    
                    if (_noteView.hidden&&_cancelDepositView.hidden) {
                        CGRect framey=_lastView.frame;
                        framey.origin.y=_referLineLabel.frame.origin.y+_referLineLabel.frame.size.height+20;
                        _lastView.frame=framey;
                    }

                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                        
                        [Global loginViewController:self noteStr:requestResultStr];
                        ///  [Global loginViewController:self];
                    }
                    
                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
        
    }
}

-(IBAction)confirmCancleClick:(id)sender
{
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        [params setObject:_DocTypeStr forKey:@"DocType"];
        [params setObject:_DocNumStr forKey:@"DocNum"];
        [params setObject:guideCodeStr forKey:@"GuideCode"];
        [params setObject:_refundMoneyTextField.text forKey:@"RSubscription"];
         [params setObject:_textView.text forKey:@"Remark"];
        
        [HttpRequest requestData:@"Guide/CancelDocument" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    
                    if ([self.delegate respondsToSelector:@selector(confirmCancelOrderOrDepositBtnClick)]) {
                        [self.delegate confirmCancelOrderOrDepositBtnClick];
                    }
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                        
                        [Global loginViewController:self noteStr:requestResultStr];
                        ///  [Global loginViewController:self];
                    }
                    
                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
        
    }

}
- (void)handleSwitchEvent:(ZJSwitch *)sender
{
   _refundMoneyTextField.text=@"";
    if (sender.on==1) {
        _cancelDepositMoneyView.hidden=NO;
       
//
//        _depositView.hidden=NO;
        
//        CGRect rect1=_lastView.frame;
//        rect1.origin.y=537;
//        _lastView.frame=rect1;

    }
    else
    {
        _cancelDepositMoneyView.hidden=YES;
//        CGRect lastViewFrame=_cashierLastView.frame;
//        lastViewFrame.origin.y=543;
//        _cashierLastView.frame=lastViewFrame;
//        
//        _depositView.hidden=YES;
//        CGRect rect1=_lastView.frame;
//        rect1.origin.y=437;
//        _lastView.frame=rect1;
    }
    
    CGRect lastViewFrame=_lastView.frame;
    lastViewFrame.origin.y=_cancelDepositView.frame.origin.y+_cancelDepositView.frame.size.height+20;
    _lastView.frame=lastViewFrame;
   
    
}

-(void)selectGuideBtnClick:(UIButton *)sender
{
    if (guideIsOpen) {
        _guideListViewContainer.hidden=YES;
        [UIView animateWithDuration:0.5 animations:^{
        
            CGRect frame=_guideListViewContainer.frame;
            
            frame.size.height=1;
            [_guideListViewContainer setFrame:frame];
            
        } completion:^(BOOL finished){
            guideIsOpen=NO;
        }];
        
    }
    else
    {
        [self requestGuideList];
        _guideListViewContainer.hidden=NO;
        CGRect frame1=_guideListViewContainer.frame;
        frame1.origin.y=111;
        [_guideListViewContainer setFrame:frame1];
        
        [UIView animateWithDuration:0.5 animations:^{
           
            CGRect frame=_guideListViewContainer.frame;
            
            frame.size.height=657;
            [_guideListViewContainer setFrame:frame];
            
        } completion:^(BOOL finished){
            guideIsOpen=YES;
        }];
        
    }

}
-(void)requestGuideList
{
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        [HttpRequest requestData:@"Guide/GuideList" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    [guideCodeArray removeAllObjects];
                    [guideNameArray removeAllObjects];
                    NSMutableArray *mGuidesArray=[severDataDict.dataDict objectForKey:@"DataLine"];
                    for (int i=0; i<mGuidesArray.count; i++) {
                        [guideCodeArray addObject:[[mGuidesArray objectAtIndex:i] objectForKey:@"UserCode"]];
                        [guideNameArray addObject:[[mGuidesArray objectAtIndex:i] objectForKey:@"UserName"]];
                    }
                    // NSLog(@"guideCodeArray==%@",guideCodeArray);
                    //
                    
                    [_guideListTableView reloadData];
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
        
    }
    
}

-(void)alphaViewClick
{
//    if ([self.delegate respondsToSelector:@selector(CancelOrderAlphaViewClick)]) {
//        [self.delegate CancelOrderAlphaViewClick];
//    }
    CGRect viewFrame=_mainView.frame;
    viewFrame.origin.y=0;
    _mainView.frame=viewFrame;
    [_textView resignFirstResponder];
     [_refundMoneyTextField resignFirstResponder];

    if (self.view!=nil) {
        
        [self removeFromParentViewController];
        [self.view removeFromSuperview];
        
    }

}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
        return guideCodeArray.count;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
        return 55.0f;
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   
        static NSString * const  GuideListIdentifier = @"GuideListCellIdentifier";
        GuideListTableViewCell *cell=( GuideListTableViewCell *)[tableView dequeueReusableCellWithIdentifier: GuideListIdentifier];
        if (cell==nil) {
            NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"GuideListTableViewCell" owner:self options:nil];
            cell = [array objectAtIndex:0];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        if (guideNameArray.count>0) {
            cell.guideNameLabel.text=[guideNameArray objectAtIndex:indexPath.row];
        }
        return cell;
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
 
            // if ([guideOrAllocateStr isEqualToString:@"GUIDE"]) {
        
        guideCodeStr=[guideCodeArray objectAtIndex:indexPath.row];
        
        _guideListViewContainer.hidden=YES;
        [UIView animateWithDuration:0.5 animations:^{
          
            CGRect frame=_guideListViewContainer.frame;
            
            frame.size.height=1;
            [_guideListViewContainer setFrame:frame];
            
        } completion:^(BOOL finished){
            guideIsOpen=NO;
        }];
        _guideNameLabel.text=[guideNameArray objectAtIndex:indexPath.row];
        // }
   // [self resizeLabel1:_guideNameLabel];
    [Global resizeForLable:_guideNameLabel WithText:_guideNameLabel.text parentView:self.view];
    CGRect frameK=_guideNameLabel.frame;
    frameK.origin.x=_guideNameArrow.frame.origin.x-frameK.size.width-5;
    _guideNameLabel.frame=frameK;
    
}
-(void)keyBordDoneClick
{
    [UIView animateWithDuration:0.3 animations:^{
        CGRect viewFrame=_mainView.frame;
        viewFrame.origin.y=0;
        _mainView.frame=viewFrame;
    } completion:^(BOOL finished){
        
    }];
}

//- (BOOL)textFieldShouldReturn:(UITextField *)textField
//{
//    if (textField==_refundMoneyTextField) {
//        [UIView animateWithDuration:0.3 animations:^{
//            CGRect viewFrame=_mainView.frame;
//            viewFrame.origin.y=0;
//            _mainView.frame=viewFrame;
//        } completion:^(BOOL finished){
//            
//        }];
//
//    }
//    return YES;
//}
-(void)refundMoneyTextFieldBeginInput
{
    [UIView animateWithDuration:0.3 animations:^{
//        CGRect viewFrame=_mainView.frame;
//        viewFrame.origin.y=-(_cancelDepositView.frame.origin.y+_cancelDepositView.frame.size.height+360-768);
//        _mainView.frame=viewFrame;
        CGFloat offset=0.0;
        CGRect frameA=_cancelDepositView.frame;
        frameA.origin.y=768-([Global getKeyboardHeight]+_cancelDepositMoneyView.frame.size.height+_cancelDepositMoneyView.frame.origin.y);
        offset=frameA.origin.y-_cancelDepositView.frame.origin.y;
        
        CGRect viewFrame=_mainView.frame;
        viewFrame.origin.y=offset;
        _mainView.frame=viewFrame;
    } completion:^(BOOL finished){
        
    }];
    
    
  


}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    if(textField==_refundMoneyTextField)
    {
        [self performSelector:@selector(refundMoneyTextFieldBeginInput) withObject:nil afterDelay:0.1];
        
    }
    return YES;
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
    if (textField==_refundMoneyTextField)
    {
        [UIView animateWithDuration:0.3 animations:^{
            CGRect viewFrame=_mainView.frame;
            viewFrame.origin.y=0;
            _mainView.frame=viewFrame;
        } completion:^(BOOL finished){
            
        }];
        
    }
}

- (void)textViewDidChange:(UITextView *)textView
{
    if (textView==_textView) {
        if (textView.text.length == 0) {
            _textViewLabel.hidden=NO;
            _textViewImage.hidden=NO;
        }
        else
        {
            _textViewImage.hidden=YES;
            _textViewLabel.hidden=YES;
            
        }
        
    }
}
-(void)textviewBeginInput
{
    [UIView animateWithDuration:0.3 animations:^{
//        CGRect viewFrame=_mainView.frame;
//        viewFrame.origin.y=-(_lastView.frame.origin.y+_lastView.frame.size.height+360-768);
//        _mainView.frame=viewFrame;
        
        CGFloat offset=0.0;
        CGRect frameA=_lastView.frame;
        frameA.origin.y=768-([Global getKeyboardHeight]+_textView.frame.size.height+_textView.frame.origin.y);
        offset=frameA.origin.y-_lastView.frame.origin.y;
        
        CGRect viewFrame=_mainView.frame;
        viewFrame.origin.y=offset;
        _mainView.frame=viewFrame;

    } completion:^(BOOL finished){
        
    }];
    
    
}
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
    if (textView==_textView)
    {
         [self performSelector:@selector(textviewBeginInput) withObject:nil afterDelay:0.1];
        
    }
    
    return YES;
}
- (void)textViewDidEndEditing:(UITextView *)textView
{
    if (textView==_textView)
    {
       
        [UIView animateWithDuration:0.3 animations:^{
            CGRect viewFrame=_mainView.frame;
            viewFrame.origin.y=0;
            _mainView.frame=viewFrame;
        } completion:^(BOOL finished){
            
        }];
        
        
    }
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
